package system

import (
	"context"

	genSysRule "admin_template/bff/admin/hertz_gen/system/sys_rule"
	"admin_template/bff/admin/internal/service"
	"github.com/cloudwego/hertz/pkg/app"
)

type RuleRepo interface {
	service.Face
	ListByRoleID(ctx context.Context, roleID int64) ([]*genSysRule.Info, error)
}

type RuleService struct {
	*Service
}

func NewRuleService(s *Service) *RuleService {
	return &RuleService{s}
}

// Add .
// @router /v1/system/rule [POST]
func (s *RuleService) Add(ctx context.Context, c *app.RequestContext) {
	var req genSysRule.AddRequest
	s.AddFunc(s.ruleRepo, &req, "ruleRepo", "规则已存在", ctx, c)
}

// UpdateInfo .
// @router /v1/system/rule [PUT]
func (s *RuleService) UpdateInfo(ctx context.Context, c *app.RequestContext) {
	var req genSysRule.UpdateRequest
	s.UpdateInfoFunc(s.ruleRepo, &req, "ruleRepo", "规则已存在", ctx, c)
}

// Del .
// @router /v1/system/rule [DELETE]
func (s *RuleService) Del(ctx context.Context, c *app.RequestContext) {
	s.DelFunc(s.ruleRepo, "ruleRepo", ctx, c)
}

// UpdateState .
// @router /v1/system/rule/state [PUT]
func (s *RuleService) UpdateState(ctx context.Context, c *app.RequestContext) {
	s.UpdateStateFunc(s.ruleRepo, "ruleRepo", ctx, c)
}

// List .
// @router /v1/system/rule [GET]
func (s *RuleService) List(ctx context.Context, c *app.RequestContext) {
	var req genSysRule.ListRequest
	s.ListFunc(s.ruleRepo, &req, "ruleRepo", ctx, c)
}

// All .
// @router /v1/system/rule/all [GET]
func (s *RuleService) All(ctx context.Context, c *app.RequestContext) {
	var req genSysRule.AllRequest
	s.AllFunc(s.ruleRepo, &req, "ruleRepo", ctx, c)
}
